<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <script type="text/javascript">  
            function retornaEvento(args) {  
                if(args.validationFailed) {  
                    cadmedida.show();
                }else{
                    cadmedida.hide();
                }
            }
        </script>         
    </h:head>
    <h:body>
        <p:dialog header="Novo" position="center" resizable="false"
                  width="400"
                  modal="true" widgetVar="cadmedida" id="dlgMedida">
            <p:outputPanel>
                <p:growl id="alerta">  
                </p:growl>
                <h:form prependId="true">
                    <h:panelGrid columns="2">
                        <h:outputText value="Nome:"/>
                        <p:inputText value="#{medidaController.medida.nome}" required="true" requiredMessage="Campo [nome] é Obrigatório!" size="30"/>
                        
                        <p:commandButton update="alerta,formMedida" value="Salvar"
                                         process="@form"
                                         image="ui-icon-disk" action="#{medidaController.adicionarMedida}" oncomplete="retornaEvento(args)" />
                    </h:panelGrid>
                </h:form>
            </p:outputPanel>
        </p:dialog>
    </h:body>
</html>